package com.neu.service;

import com.github.pagehelper.PageHelper;
import com.neu.dao.ShoppingFeedbackMapper;
import com.neu.domain.ShoppingAdExample;
import com.neu.domain.ShoppingFeedback;
import com.neu.domain.ShoppingFeedbackExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.time.LocalDateTime;
import java.util.List;

import javax.annotation.Resource;

/**
 * @author Yogeek
 * @date 2018/8/27 11:39
 */
@Service
public class ShoppingFeedbackService {
	@Resource
	private ShoppingFeedbackMapper feedbackMapper;
	public List<ShoppingFeedback> querySelective(String UserName, String content, Integer page, Integer limit, String sort, String order){
			ShoppingFeedbackExample example=new ShoppingFeedbackExample();
	        ShoppingFeedbackExample.Criteria criteria = example.createCriteria();

	        if (!StringUtils.isEmpty(UserName)) {
	            criteria.andUsernameLike("%" + UserName + "%");
	        }
	        if (!StringUtils.isEmpty(content)) {
	            criteria.andContentLike("%" + content + "%");
	        }
	        criteria.andDeletedEqualTo(false);

	        if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
	            example.setOrderByClause(sort + " " + order);
	        }

	        PageHelper.startPage(page, limit);
	        return feedbackMapper.selectByExample(example);
	}
    
}
